package com.util;

/**
 * Created by chen on 2017/3/12.
 */
public class SqlUtil {
    /**
     * 获得所有数据的sql
     *
     * @param sql
     * @return
     */
    public static String getCountSql(String sql) {
        String countSql = "select count(*) from ( " + sql + ")" + " t";
        return countSql;
    }

    /**
     * 获得my分页的sql
     *
     * @param sql
     * @param pn 页数
     * @param pageSize 每页多少条数据
     * @return
     */
    public static String getMysqlPageSql(String sql, int pn, int pageSize) {
        String pageSql = sql + " limit " + ((pn - 1) * pageSize) + "," + pageSize;
        return pageSql;
    }
}
